/*
 * @Author: 许警 11378748333@
 * @Date: 2024-07-05 10:35:45
 * @LastEditors: 许警 11378748333@
 * @LastEditTime: 2024-07-05 10:52:07
 * @FilePath: /hsxlsystem/src/hooks/useCopy.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Component, h } from 'vue'
import Icon from '@ant-design/icons-vue'
import { useClipboard } from '@vueuse/core'
import { message } from 'ant-design-vue'
const { copy, isSupported } = useClipboard()

export function renderDesignIcon(icon, conf) {
  return h(Icon, conf, { component: () => h(icon) })
}

export default function useCopy(text) {
  if (navigator.clipboard) {
    const { copy } = useClipboard()
    copy(text)
  } else {
    const input = document.createElement('input')
    input.setAttribute('value', text)
    document.body.appendChild(input)
    input.select()
    document.execCommand('copy')
    document.body.removeChild(input)
  }
  message.success(`复制成功`)
}
